#coding=utf-8
import datetime

from elixir import *

class TradableShare(Entity):
    using_options(tablename='tradableshares', order_by='-beginning')
    
    quantity = Field(Integer)
    beginning = Field(Date)
    created_at = Field(Date, default=datetime.date.today)
    
    stock = ManyToOne('Stock')
    
    def __init__(self, stock, quantity, beginning):
        self.stock = stock
        self.quantity = quantity
        self.beginning = beginning
        
    def __str__(self):
        return '%s:%d(%s)'%(self.stock, self.quantity, self.beginning)
    __repr__ = __str__
